<!--
 * @Description: file content
 * @Author: oooh
 * @Date: 2024-04-15 17:33:11
 * @LastEditors: oooh
 * @LastEditTime: 2024-06-21 17:33:20
 * @FilePath: \Civil_Servant_Performance_PC\src\views\index.vue
-->
<template>
  <keep-alive>
    <component :is="dynamicComponent"></component>
  </keep-alive>
</template>

<script>
import GeneralUser from '@/views/workbench/general-user'
import departmentOffice from '@/views/workbench/department-office'
import performanceOffice from '@/views/workbench/performance-office'
import disciplineInspectionOffice from '@/views/workbench/discipline-inspection-office'
import leader from '@/views/workbench/leader'
import other from '@/views/workbench/other'
export default {
  name: 'index',
  props: {},
  components: {
    GeneralUser,
    departmentOffice,
    disciplineInspectionOffice,
    performanceOffice,
    leader,
    other
  },
  data() {
    return {
      dynamicComponent: 'department-office',
      roleList: [
        {
          role: 'leadershipGroup',
          component: 'leader',
          remark: '党政领导'
        },

        {
          role: 'partLeader',
          component: 'leader',
          remark: '分管领导'
        },
        {
          role: 'performanceOffice',
          component: 'performance-office',
          remark: '绩效办'
        },
        {
          role: 'disciplineOffice',
          component: 'discipline-inspection-office',
          remark: '纪检办'
        },
        {
          role: 'deptManager',
          component: 'department-office',
          remark: '站办所'
        },
        {
          role: 'cadre',
          component: 'General-user',
          remark: '普通干部  '
        },
        {
          role: 'basic',
          component: 'General-user',
          remark: '基础角色  '
        }
      ]
    }
  },
  created() {
    let isRole = true
    for (let item of this.roleList) {
      // 验证用户是否具备某角色
      if (this.$auth.hasRole(item.role)) {
        isRole = false
        this.dynamicComponent = item.component
        return
      }
    }
    if (isRole) {
      this.dynamicComponent = 'other'
    }
  },
  mounted() {},
  beforeCreate() {
    // this.$router.replace('general-user')
  },
  computed: {},
  watch: {},
  methods: {}
}
</script>

<style lang="scss"></style>
